package model;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import dao.BoxDao;

@FacesConverter(value="tipoConverter")
public class TipoConverter implements Converter{

	@Override
	public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {				
		return new BoxDao().buscaTipoBox(Integer.parseInt(arg2));
	}

	@Override
	public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {		
		BoxTipo bt = new BoxTipo();
		bt = (BoxTipo) arg2;
		bt=new BoxDao().buscaTipoBox(bt.getId());
		return bt.getDescricao();
		
	}

}
